package com.hengpeng.itfinoss.service.notice.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import com.hengpeng.common.exception.ServiceResult;
import com.hengpeng.common.persist.QueryResult;
import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.common.persist.query.constants.QueryConstants.QueryType;
import com.hengpeng.itfinbase.persist.ProjectInfo;
import com.hengpeng.itfinoss.service.ServiceFactory;
import com.hengpeng.itfinoss.service.notice.ProjectService;

@Lazy
@Service
public class ProjectServiceImpl implements ProjectService
{
	@Autowired
	private ServiceFactory serviceFactory;

	@Override
	public ServiceResult<List<ProjectInfo>> queryList(Integer pageIndex, Integer pageSize)
	{
		DynamicQuery query = new DynamicQuery(ProjectInfo.class);
		query.desc("createTime"); 
		query.setPageIndex(pageIndex);
		query.setPageSize(pageSize);
		query.setQueryType(QueryType.JDBC);
		query.setIsSearchTotalCount(true);
		QueryResult<ProjectInfo> requery = serviceFactory.getPersistService().findWithPage(ProjectInfo.class, query);
		Long count = requery.getTotalCount();
		ServiceResult<List<ProjectInfo>> serviceResult = new ServiceResult<List<ProjectInfo>>();// 设置返回值
		serviceResult.setReturnValue(requery.getResults());
		serviceResult.setReturnListSize(count.intValue());
		return serviceResult;
	}
}
